/**
 * “用户管理”相关接口
 */
import Http from 'utils/request'
const context = process.env.VUE_APP_CONSOLE_PATH

export default {
  queryUser: params => {
    const { current, size, ...other } = params
    return Http.fetch(
      context + '/sys_user/query',
      {
        ...other,
        current,
        size
      },
      {
        method: 'post'
      }
    )
  },

  updateUser: params =>
    Http.fetch(context + '/sys_user/info', params, {
      method: 'patch'
    }),

  updatePwd: params =>
    Http.fetch(context + '/sys_user/pwd', params, {
      method: 'patch'
    }),

  addUser: params =>
    Http.fetch(context + '/sys_user', params, {
      method: 'post'
    }),

  deleteUser: params =>
    Http.fetch(context + '/sys_user', params, {
      method: 'delete'
    }),

  /**
   * 更新用户的角色
   * @param perm
   */
  updateUserRoles: params =>
    Http.fetch(context + '/sys_user/role', params, {
      method: 'patch'
    }),

  /**
   * “选项”相关接口
   */
  listRoleOptions: params =>
    Http.fetch(context + '/option/role', params, {
      method: 'get',
      hasErrMsg: true
    })
}
